package com.yoso.base.infrastructure.utils;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.yoso.base.infrastructure.constants.DatePattern;
import org.jetbrains.annotations.NotNull;

import java.util.Date;

/**
 * @author shizejin
 */
public class IdUtil {

    /**
     * @return 主键ID
     */
    @NotNull
    public static String buildId() {
        return RandomUtil.simpleUUID();
    }

    /**
     * @return 订单编号: 当前日期+6位随机数
     */
    @NotNull
    public static String buildOrderId() {
        String dateTimeMxId = DateUtil.format(new Date(), DatePattern.DATE_ID_MX_PATTERN);
        String random = RandomUtil.randomNumbers(6);
        return dateTimeMxId + random;
    }

    /**
     * @return 商品编号 12位随机数
     */
    @NotNull
    public static String buildCommodityId() {
        return RandomUtil.randomNumbers(12);
    }
}
